import request from '@/axios'
import {SysAccountChangePasswordQo, SysAccountDetailVo, SysAccountEditQo, SysAccountListVo, SysAccountSearchQo} from './types'
import {BaseDeleteQo} from '@/base/api/BaseQo'
import {KeyLabelValueVo} from '@/base/api/KeyLabelValueVo'

export const sysAccountPageApi = (data: SysAccountSearchQo): Promise<IResponse<Array<SysAccountListVo>>> => {
    return request.post({url: '/sysAccount/page.adw', data})
}

export const sysAccountDetailApi = (id: number): Promise<IResponse<SysAccountDetailVo>> => {
    const data = {id}
    return request.post({
        url: '/sysAccount/detail.adw',
        data
    })
}

export const sysAccountAddApi = (data: SysAccountEditQo): Promise<IResponse<number>> => {
    return request.post({url: '/sysAccount/add.adw', data})
}

export const sysAccountUpdateApi = (data: SysAccountEditQo): Promise<IResponse<void>> => {
    return request.post({url: '/sysAccount/update.adw', data})
}

export const sysAccountDeleteApi = (data: BaseDeleteQo): Promise<IResponse<void>> => {
    return request.post({url: '/sysAccount/delete.adw', data})
}

export const sysAccountGetMyInfoApi = (): Promise<IResponse<SysAccountDetailVo>> => {
    return request.post({url: '/sysAccount/getMyInfo.adw',})
}

export const sysAccountUpdateMyInfoApi = (data: SysAccountEditQo): Promise<IResponse<void>> => {
    return request.post({url: '/sysAccount/updateMyInfo.adw', data})
}

export const sysAccountUpdatePasswordApi = (data: SysAccountChangePasswordQo): Promise<IResponse<void>> => {
    return request.post({url: '/sysAccount/updatePassword.adw', data})
}

// [[ OnflowGenerator Range (- selectFunctions -) Start ]]
export const selectSysAccountNameListApi = (
    data: SysAccountSearchQo
): Promise<IResponse<Array<KeyLabelValueVo>>> => {
    return request.post({url: '/sysAccount/selectNameList.adw', data})
}
// [[ OnflowGenerator Range (- selectFunctions -) End ]]
